﻿using System;
using System.Collections.Generic;
using System.Text;

namespace daSyntaxAnalyser.SyntaxTree
{
    using daBase.Objects;

    public class IntervalsVariableExpressionElement : VariableExpressionElement
    {
        private List<IntervalVariableExpressionElement> intervals;

        public List<IntervalVariableExpressionElement> Intervals { get { return intervals; } set { intervals = value; } }

        public IntervalsVariableExpressionElement(TokenInfo StartInfo, List<IntervalVariableExpressionElement> Intervals, List<TokenInfo> Comments)
            : base(StartInfo, Comments)
        {
            intervals = Intervals;
        }

        public override string ToString()
        {
            return (intervals != null) ? string.Format("[{0}]", intervals.Join(", ")) : "[]";
        }

        protected override IEnumerator<ISyntaxTreeElement> CreateEnumerator()
        {
            if (intervals != null)
                foreach (IntervalVariableExpressionElement interval in intervals)
                    yield return interval;
        }
    }
}
